<html>
<head><meta charset="utf-8"><title>zero-cost futures · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html">zero-cost futures</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="151523262"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151523262" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151523262">(Dec 12 2018 at 13:09)</a>:</h4>
<p>Are futures really zero-cost ? I can't seem to figure out how to use them without adding overhead, or unsafety :/</p>



<a name="151523328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151523328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151523328">(Dec 12 2018 at 13:10)</a>:</h4>
<p>Like, is there a project using them to map to hardware network I/O ?</p>



<a name="151523436"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151523436" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151523436">(Dec 12 2018 at 13:12)</a>:</h4>
<p>We're using them on embedded for all I/O, even network, but it's not quite finished yet</p>



<a name="151524344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151524344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151524344">(Dec 12 2018 at 13:28)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@Oli</span> so I find it impossible to use with DMA without pushing the responsibility of pinning, which is unsafe, onto the user</p>



<a name="151524412"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151524412" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151524412">(Dec 12 2018 at 13:28)</a>:</h4>
<p>The only way I've found of making this safe is to heap allocate the future</p>



<a name="151524432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151524432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151524432">(Dec 12 2018 at 13:29)</a>:</h4>
<p>I also found the LocalWaker API extremely weird - if you are doing DMA then there is no LocalWaker</p>



<a name="151524549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151524549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151524549">(Dec 12 2018 at 13:31)</a>:</h4>
<p>This makes Poll very weird too: Poll::Pending means "don't poll me again until the LocalWaker is awoken", but since there is no way for that to happen, futures will never get polled</p>



<a name="151524573"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151524573" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151524573">(Dec 12 2018 at 13:31)</a>:</h4>
<blockquote>
<p>the responsibility of pinning, which is unsafe, onto the user</p>
</blockquote>
<p>hu? no, you can create <code>Pin</code> in safe code. or do you mean specifically pinning on the stack? AFAIK there's a safe stack pinning macro in some crate</p>



<a name="151524621"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151524621" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151524621">(Dec 12 2018 at 13:32)</a>:</h4>
<p>One could emulate a LocalWaker using a second thread, but... that's definetely not zero-cost.</p>



<a name="151524631"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151524631" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151524631">(Dec 12 2018 at 13:32)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> there is <code>pin_mut!</code> in <code>pin_utils</code>, is that what you mean? Take a look at the macro implementation. . .</p>



<a name="151524647"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151524647" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151524647">(Dec 12 2018 at 13:33)</a>:</h4>
<p><a href="https://github.com/rust-lang-nursery/pin-utils/blob/master/src/stack_pin.rs" target="_blank" title="https://github.com/rust-lang-nursery/pin-utils/blob/master/src/stack_pin.rs">https://github.com/rust-lang-nursery/pin-utils/blob/master/src/stack_pin.rs</a></p>



<a name="151524650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151524650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151524650">(Dec 12 2018 at 13:33)</a>:</h4>
<p>you aren't asking for <em>transitively</em> safe code, are you? you're not going to get far with that^^ (anywhere in Rust)</p>



<a name="151524718"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151524718" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151524718">(Dec 12 2018 at 13:34)</a>:</h4>
<p>no, i'm just saying that this is very limiting</p>



<a name="151524737"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151524737" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151524737">(Dec 12 2018 at 13:35)</a>:</h4>
<p>if you want to pin within a method, and store the pin as an struct field, then this macro won't help</p>



<a name="151524753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151524753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151524753">(Dec 12 2018 at 13:35)</a>:</h4>
<p>fair. but what you said above was basically "pinning requires the user to use unsafe", and that's definitely wrong</p>



<a name="151524765"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151524765" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151524765">(Dec 12 2018 at 13:35)</a>:</h4>
<p>let me rephrase: the responsibility of pinning properly is pushed down to the user</p>



<a name="151524826"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151524826" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151524826">(Dec 12 2018 at 13:36)</a>:</h4>
<p>sure. you asked for zero-cost yourself, that's the only way to get zero-cost :D</p>



<a name="151524849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151524849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151524849">(Dec 12 2018 at 13:37)</a>:</h4>
<p>I think that's bad, as in, there is no real way to abstract over pinning</p>



<a name="151524866"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151524866" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151524866">(Dec 12 2018 at 13:37)</a>:</h4>
<p>if I want to create a type that takes ownership of a future, and pins it, that cannot be done at zero-cost</p>



<a name="151524876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151524876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151524876">(Dec 12 2018 at 13:37)</a>:</h4>
<p>The type cannot be !Move, the type cannot "pin itself", etc.</p>



<a name="151524950"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151524950" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151524950">(Dec 12 2018 at 13:38)</a>:</h4>
<p>Pushing the responsibility of pinning to the user is the only thing that my code can do, that's good for my code, but bad for its users</p>



<a name="151524990"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151524990" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151524990">(Dec 12 2018 at 13:39)</a>:</h4>
<p>it's no less and no more bad than pushing the responsibility of safe mutation out to the user using <code>&amp;mut self</code></p>



<a name="151525000"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151525000" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151525000">(Dec 12 2018 at 13:39)</a>:</h4>
<p>and it's just as compositional</p>



<a name="151525084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151525084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151525084">(Dec 12 2018 at 13:40)</a>:</h4>
<blockquote>
<p>if I want to create a type that takes ownership of a future, and pins it, that cannot be done at zero-cost</p>
</blockquote>
<p>your type then needs to expose that it requires pinning, just like existing code exposes that it requires mutation</p>



<a name="151525103"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151525103" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151525103">(Dec 12 2018 at 13:41)</a>:</h4>
<p>is it possible to express that? I have literally 1 day of experience with async / futures, on Discord nobody suggested that it was doable.</p>



<a name="151525219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151525219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151525219">(Dec 12 2018 at 13:43)</a>:</h4>
<p>you need "recursive" or "structural" pinning, which (bad for you but not for your users) is not very ergonomic to do currently. and then your methods take <code>Pin&lt;&amp;mut self&gt;</code>, propagating the requirements outwards.</p>



<a name="151525236"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151525236" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151525236">(Dec 12 2018 at 13:43)</a>:</h4>
<p>see <a href="https://docs.rs/pin-utils/0.1.0-alpha.3/pin_utils/macro.unsafe_pinned.html" target="_blank" title="https://docs.rs/pin-utils/0.1.0-alpha.3/pin_utils/macro.unsafe_pinned.html">https://docs.rs/pin-utils/0.1.0-alpha.3/pin_utils/macro.unsafe_pinned.html</a></p>



<a name="151525755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151525755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151525755">(Dec 12 2018 at 13:55)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> but then my users still need to pin my type right?</p>



<a name="151525995"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151525995" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151525995">(Dec 12 2018 at 13:59)</a>:</h4>
<p>yes they do :/ its unclear to me whether the difference between pinning my type or pinning the future matters</p>



<a name="151526275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151526275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151526275">(Dec 12 2018 at 14:03)</a>:</h4>
<p>Do you know how to implement Futures for which LocalWaker makes no sense?</p>



<a name="151526766"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151526766" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151526766">(Dec 12 2018 at 14:11)</a>:</h4>
<blockquote>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> but then my users still need to pin my type right?</p>
</blockquote>
<p>of course. if you mutate anything, you propagate the <code>&amp;mut</code> outwards. if you access pinned data that you cann promise yourself is pinned (because you boxed it or so), you propagate the <code>Pin</code> outwards</p>



<a name="151526779"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151526779" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151526779">(Dec 12 2018 at 14:11)</a>:</h4>
<p>you cannot magically disappear the fact that data needs to be pinned</p>



<a name="151526845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151526845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151526845">(Dec 12 2018 at 14:12)</a>:</h4>
<blockquote>
<p>Do you know how to implement Futures for which LocalWaker makes no sense?</p>
</blockquote>
<p>I'm afraid not -- I don't know anything about futures.<br>
I was just commenting on the pinning aspect as that's something I studied in some depth :)</p>



<a name="151526889"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151526889" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151526889">(Dec 12 2018 at 14:13)</a>:</h4>
<p>it took a bit to grok the most important pieces of pinning, but I don't think i groked them all</p>



<a name="151526910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151526910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151526910">(Dec 12 2018 at 14:13)</a>:</h4>
<p>it is quite an interesting abstraction</p>



<a name="151526983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151526983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151526983">(Dec 12 2018 at 14:14)</a>:</h4>
<p>I ended up wishing !Move a couple of times while playing with it, but now I think its more flexible than !Move</p>



<a name="151527022"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151527022" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151527022">(Dec 12 2018 at 14:15)</a>:</h4>
<p>it lets you make objects any type !Move when you need it</p>



<a name="151527208"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151527208" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151527208">(Dec 12 2018 at 14:17)</a>:</h4>
<p>anyways, now I still need to figure out how to make the futures actually work with other people executors expecting a LocalWaker that does something</p>



<a name="151531300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151531300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151531300">(Dec 12 2018 at 15:13)</a>:</h4>
<p>Also, remember that "zero-cost" means "the abstraction has no more runtime overhead than the non-abstracted version"</p>



<a name="151531412"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151531412" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151531412">(Dec 12 2018 at 15:14)</a>:</h4>
<p>But not "I don't like the abstraction" or "it's not a very abstract abstraction" or "it's a leaky abstraction"</p>



<a name="151536389"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151536389" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151536389">(Dec 12 2018 at 16:26)</a>:</h4>
<p>The non-abstraction version does not require spawning threads nor allocating memory.</p>



<a name="151536391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151536391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151536391">(Dec 12 2018 at 16:26)</a>:</h4>
<p>With respect to LocalWaker, the non-abstracted version works, the abstracted version "doesn't"</p>



<a name="151536468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151536468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151536468">(Dec 12 2018 at 16:27)</a>:</h4>
<p>One can make it work by not using the abstraction how it is intended to be used.</p>



<a name="151536478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151536478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151536478">(Dec 12 2018 at 16:27)</a>:</h4>
<p>But then one might arguable be better off with a different abstraction</p>



<a name="151536503"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151536503" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151536503">(Dec 12 2018 at 16:28)</a>:</h4>
<p>Sadly, that's not allowed, because Rust <code>async fn</code> requires using <code>Future</code></p>



<a name="151579329"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151579329" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zoxc <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151579329">(Dec 13 2018 at 02:06)</a>:</h4>
<p>I plan to avoid the <code>Future</code> trait with <code>#[async]</code> proc macros, which was originally the plan for them</p>



<a name="151601453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151601453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151601453">(Dec 13 2018 at 11:38)</a>:</h4>
<p><span class="user-mention" data-user-id="116466">@Zoxc</span> does that mean that I can use <code>async fn</code> that return <code>-&gt; impl MyFutureTrait</code>  ?</p>



<a name="151616919"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/zero-cost%20futures/near/151616919" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zoxc <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/zero-cost.20futures.html#151616919">(Dec 13 2018 at 15:51)</a>:</h4>
<p>It would be <code>#[async] fn</code>, but yes</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>